package com.xoa.controller.party;


import com.xoa.model.party.GridEvent;
import com.xoa.service.document.DocumentSerivce;
import com.xoa.service.party.GridEventService;
import com.xoa.util.common.wrapper.BaseWrapper;
import com.xoa.util.common.wrapper.BaseWrappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by gsb on 2017/9/6.
 */
@RestController
@RequestMapping("/gridEventParting")
public class GridEventPartingController {
    @Autowired
    private GridEventService gridEventService;

    /**
     * 代办
     * @param request
     * @param page
     * @param pageSize
     * @return
     */
    @RequestMapping("/selWillGridSendOrReceive")
    public BaseWrappers selWillDocSendOrReceive(HttpServletRequest request,
                                                @RequestParam(name = "page", required = false, defaultValue = "1") Integer page,
                                                @RequestParam(name = "pageSize", required = false, defaultValue = "10") Integer pageSize
    ) {
        return gridEventService.selWillGridSendOrReceive(request, null,page, pageSize, DocumentSerivce.PRCS_FLAG_WILL, DocumentSerivce.PRCS_FLAG_OVER);
    }
    /**
     * 已办
     * @param request
     * @param page
     * @param pageSize
     * @return
     */
    @RequestMapping("/selWillGridOpenOrReceive")
    public BaseWrappers selWillGridOpenOrReceive(HttpServletRequest request,
                                                 @RequestParam(name = "page", required = false, defaultValue = "1") Integer page,
                                                 @RequestParam(name = "pageSize", required = false, defaultValue = "10") Integer pageSize
    ) {
        return gridEventService.selWillGridSendOrReceive(request,null, page, pageSize, DocumentSerivce.PRCS_FLAG_OVER, DocumentSerivce.PRCS_FLAG_OVER);
    }

    /**
     * 添加
     * @param gridEvent
     * @return
     */
    @RequestMapping("/addGridEvent")
     public BaseWrapper addGridEvent(GridEvent gridEvent, String dateTime
    ) {
        gridEvent.setEventParting("2");
        return gridEventService.addGridEvent(gridEvent,dateTime);
    }

    /**
     * 列表
     * @param request
     * @param page
     * @param pageSize
     * @param flowStatus
     * @return
     */
    @RequestMapping("/selectbYfLOWstuts")
    public BaseWrappers selectbYfLOWstuts(HttpServletRequest request, boolean useFlag, Integer page, Integer pageSize, String flowStatus
    ) {
        return gridEventService.selectbYfLOWstuts(request,useFlag,page,pageSize,flowStatus, DocumentSerivce.PRCS_FLAG_OVER);
    }
    @RequestMapping("/selectGridEvent")
    public BaseWrappers selectGridEvent(HttpServletRequest request, HttpServletResponse response, Integer page, Integer pageSize, String userId,
                                        String gridId, String exentType, String flowStatus, String beginDate, String endDate, String exportId){
  return gridEventService.selectGridEvent(request,response,page,pageSize,userId,gridId,exentType,flowStatus,beginDate,endDate,exportId, DocumentSerivce.PRCS_FLAG_OVER);
    }


    @RequestMapping("/getStatistics")
    public BaseWrappers checkStatistics(String timeType, String queryType) {
        return gridEventService.getStatistics(timeType,queryType, DocumentSerivce.PRCS_FLAG_OVER);
    }
    @RequestMapping("/selectByPrimaryKey")
    public BaseWrapper selectByPrimaryKey(Integer eventId, HttpServletRequest request) {
        return gridEventService.selectByPrimaryKey(eventId,request);
    }
    @RequestMapping("/deleteByPrimaryKey")
    public BaseWrapper deleteByPrimaryKey(Integer eventId) {
        return gridEventService.deleteByPrimaryKey(eventId);
    }
    @RequestMapping("/updateByPrimaryKeySelective")
    public BaseWrapper updateByPrimaryKeySelective(GridEvent gridEvent, String dateTime) {
        gridEvent.setEventParting("2");
        return gridEventService.updateByPrimaryKeySelective(gridEvent,dateTime);
    }
    @RequestMapping("/getCountByname")
    public BaseWrappers getCountByname(String timeType) {
        return gridEventService.getCountByname(timeType, DocumentSerivce.PRCS_FLAG_OVER);
    }
}
